package com.miaosha.mapper;

import com.miaosha.pojo.Stock;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface StocKMapper {

    @Select("select id,name,count,sale,version from stock where id=#{id}")
    Stock checkStock(Integer id);

    /**
     *  根据商品id扣除库存
     * @param stock
     * @return
     */
    @Update("update stock set sale=sale+1,version=version+1 where id=#{id} and version=#{version}")
    int updateSale(Stock stock);

    @Select("select * from stock where id=#{id}")
    Stock findByID(Integer id);
}
